|
|
|
|
|
|
|
usri2_auth_flags is documented as being ignored for this function (the USER_INFO_2 structure is used by other functions as well). |
|
|
|
|
|
|
|
|
At this point, I had a sudden sinking feeling. That's the trouble with writing articles in real time. What do you do when you're on a deadline, you've already invested hours in writing more than 2,000 words in a chapter, and you have no idea whether you'll be able to make it work? After a short panic break for chocolate, I took a closer look. |
|
|
|
|
|
|
|
|
The documentation clearly states that the usri2_script_path parameter and usri2_auth_flags parameters may both be NULL. Yet the error clearly indicates that the problem is with one of these parameters. |
|
|
|
|
|
|
|
|
When in doubt, I've found that it is always worthwhile to take a second look at the documentationespecially the parameters I was already setting. I noticed that the usri2_flags parameter had the following constant documented: |
|
|
|
 |
|
 |
|
|
UF_SCRIPT The logon script executed. This value must be set for LAN Manager 2.0 or Windows NT |
|
|
|
|
|
|
|
|
I had noticed earlier that the UF_NORMALACCOUNT constant was required, but I missed the UF_SCRIPT constant. Windows saw that the constant was missing and erroneously decided that the error was in the usri2_script_path parameter. Now, I don't know if that's a bug or just a misleading error result, but it does prove one point: When dealing with the Win32 API, never assume that something is true just because it happens to show up in the documentation. I realize that this is a scary thought, but don't get too depressed. Most of the time, the documentation is correct and Windows really is remarkably bug-free for a system of its complexity. Most Windows systems crash only once or twice a day (so much for not being depressed). |
|
|
|
|
|
|
|
|
In fixing this problem, I noticed that I had left out the setting of the usri2_flags parameter completely. So I added the following code: |
|
|
|
|
|
|
|
|
Private Const UF_SCRIPT = &H1
ul2.usri2_flags = UF_NORMAL_ACCOUNT Or UF_SCRIPT |
|
|
|
|
|
|
|
|
The OR operator is used to combine two constants by taking the logical Or of their bit values. This is discussed further in Tutorial 3, "A Bool and Its Bitfields Are Soon Parted." |
|
|
|
|
|
|
|
|
When I ran the program this time, it returned the result value 0. |
|
|
|
|
|